package com.easyedu.dean.service;

import com.easyedu.core.entity.po.ExamPlan;
import com.easyedu.core.exception.EasyEduException;
import com.easyedu.core.dao.ExamDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lmr
 **/
@Service
public class ExamService {

    private final ExamDao examDao;

    public ExamService(ExamDao examDao) {
        this.examDao = examDao;
    }

    public List<ExamPlan> getNeedApprovalExamTime() {
        return examDao.getNeedApprovalExamTime();
    }

    @Transactional(rollbackFor = Exception.class)
    public void approvalExamTime(Long examPlanId) {
        int i = examDao.approvalExamTime(examPlanId);
        if(i != 1){
            throw new EasyEduException(1999,"审批考试时间失败");
        }
    }
}
